<?php
/**
 * @version		$Id: view.html.php 2011.08.11 thierry $
 * @package		admin.views.server
 * @subpackage	com_projid
 * @copyright	Copyright (C) 2011 Pojid All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla view library
jimport('joomla.application.component.view');
 
/**
 * Server View
 */
class ProjidViewServer extends JView
{
		/**
	 * View form
	 *
	 * @var		form
	 */
	protected $form = null;
	/**
	 * display method of Server view
	 * @return void
	 */
	public function display($tpl = null) 
	{
		// get the Data
		$form = $this->get('Form');
		$item = $this->get('Item');
 		$script = $this->get('Script');
 		
		// Check for errors.
		if (count($errors = $this->get('Errors'))) 
		{
			JError::raiseError(500, implode('<br />', $errors));
			return false;
		}
		// Assign the Data
		$this->form = $form;
		$this->item = $item;
 		$this->script = $script;
 		
		// Set the toolbar
		$this->addToolBar();
 
		// Display the template
		parent::display($tpl);
		// Set the document
		$this->setDocument();
	}
 
	/**
	 * Setting the toolbar
	 */
	protected function addToolBar() 
	{
		JRequest::setVar('hidemainmenu', true);
		$isNew = ($this->item->id_serv == 0);
		JToolBarHelper::title($isNew ? JText::_('COM_PROJID_MANAGER_SERVER_NEW') : JText::_('COM_PROJID_MANAGER_SERVER_EDIT'));
		JToolBarHelper::save('server.save');
		JToolBarHelper::cancel('server.cancel', $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE');
	}
	/**
	 * Method to set up the document properties
	 *
	 * @return void
	 */
	protected function setDocument() 
	{
		$isNew = ($this->item->id_serv < 1);
		$document = JFactory::getDocument();
		$document->setTitle($isNew ? JText::_('COM_PROJID_SERVER_CREATING') : JText::_('COM_PROJID_SERVER_EDITING'));

	}
}